//
//  BCCodon.m
//  BioCocoa
//
//  Created by John Timmer on 8/31/04.
//  Copyright 2004 The BioCocoa Project. All rights reserved.
//
//  This code is covered by the Creative Commons Share-Alike Attribution license.
//	You are free:
//	to copy, distribute, display, and perform the work
//	to make derivative works
//	to make commercial use of the work
//
//	Under the following conditions:
//	You must attribute the work in the manner specified by the author or licensor.
//	If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
//
//	For any reuse or distribution, you must make clear to others the license terms of this work.
//	Any of these conditions can be waived if you get permission from the copyright holder.
//
//  For more info see: http://creativecommons.org/licenses/by-sa/2.5/

#import "BCCodon.h"
#import "BCSequence.h"
#import "BCAminoAcid.h"
#import "BCSymbol.h"


@implementation BCCodon


- (BCAminoAcid *) codedAminoAcid {
    return codedAminoAcid;
}

- (BCSequence *) triplet {
    NSArray *tempArray = [NSArray arrayWithObjects: firstBase, secondBase, wobbleBase, nil];
    return [BCSequence sequenceWithSymbolArray: tempArray];
}


- (NSString *) aminoAcidSymbolString {
    if ( codedAminoAcid == nil )
        return @"*";
    else
        return [codedAminoAcid symbolString];
}
    
    
- (NSString *) tripletString {
    NSMutableString *returnString = [NSMutableString stringWithString: [firstBase symbolString]];
    [returnString appendString: [secondBase symbolString]];
    [returnString appendString: [wobbleBase symbolString]];

    return [[returnString copy] autorelease];
}

- (NSString *)symbolString {
	return [[self aminoAcidSymbolString] stringByAppendingString: [NSString stringWithFormat: @"(%@)", [self tripletString]]];
}


- (NSString *) description {
    return [self tripletString];
}

- (id)copyWithZone:(NSZone *)zone {
    return self;
}

@end
